// 模拟小程序装修数据
const designData = {
  'wx123456789': [
    {
      type: 'banner',
      config: {
        height: 180,
        autoplay: true,
        interval: 3000,
        items: [
          {
            url: 'https://example.com/banner1.jpg',
            link: 'https://example.com/page1'
          },
          {
            url: 'https://example.com/banner2.jpg',
            link: 'https://example.com/page2'
          }
        ]
      }
    },
    {
      type: 'grid',
      config: {
        columns: 4,
        items: [
          {
            icon: 'https://example.com/icon1.png',
            text: '分类',
            link: '/pages/category/index'
          },
          {
            icon: 'https://example.com/icon2.png',
            text: '购物车',
            link: '/pages/cart/index'
          },
          {
            icon: 'https://example.com/icon3.png',
            text: '我的',
            link: '/pages/user/index'
          }
        ]
      }
    },
    {
      type: 'goods',
      config: {
        showType: 'list',
        items: [
          {
            image: 'https://example.com/goods1.jpg',
            title: '商品1',
            price: 99.00,
            link: '/pages/goods/detail?id=1'
          },
          {
            image: 'https://example.com/goods2.jpg',
            title: '商品2',
            price: 199.00,
            link: '/pages/goods/detail?id=2'
          }
        ]
      }
    },
    {
      type: 'tabBar',
      config: {
        items: [
          { text: '首页', icon: 'House', link: '/pages/home/index' },
          { text: '分类', icon: 'Menu', link: '/pages/category/index' },
          { text: '购物车', icon: 'ShoppingCart', link: '/pages/cart/index' },
          { text: '我的', icon: 'User', link: '/pages/user/index' }
        ],
        activeColor: '#409EFF'
      }
    }
  ]
}

const mockApi = [
  {
    url: '/api/miniapp/design',
    method: 'get',
    response: (config) => {
      // 从 URL 中获取 id 参数
      const id = config.url.split('?')[1]?.split('=')[1]
      return {
        code: 200,
        data: designData[id] || []
      }
    }
  }
]

export default mockApi 